package yxxy.c_07;

import java.util.concurrent.Callable;

/**
 * 同步和非同步方法是否可以同时调用？
 * @author zhaoxiang
 * @version 1.0
 * @Date 2019/9/16 23:48
 */
public class T {
    private synchronized void method01(){
        System.out.println(Thread.currentThread().getName() +" method01 start ...");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "method01 end ...");
    }

    private void method02(){
        System.out.println(Thread.currentThread().getName() +" method02 start ...");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "method02 end ...");
    }

    public static void main(String[] args) {
        T t = new T();
        /*new Thread(()->t.m1(), "t1").start();
		new Thread(()->t.m2(), "t2").start();*/
        new Thread(new Runnable() {
            @Override
            public void run() {
                t.method01();
            }
        },"t1").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                t.method02();
            }
        },"t2").start();
}
}
